const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')

//thread-loader
module.exports = {
    entry: './js/index.js',
    output: {
        filename: 'index.js',
        path: path.resolve(__dirname, 'dist')
    },
    module: {
        rules: [
            /*
            每一个loader会开启进程，开启有时间大概600ms  进行通信也有时间 适合大型项目 小型项目反而会慢
            只有工作消耗时间过长，才需要多进行打包
            一般用于js
            */
            {
                test: /\.js$/i,
                exclude: /node_modules/,
                use: [
                    //开启多线程打包
                    {
                        loader: 'thread-loader',
                        options: {
                            workers: 2//进程
                        }
                    },
                ],

            }

        ]
    },
    plugins: [
        new HtmlWebpackPlugin({
            template: "./index.html"
        }),



    ],
    mode: 'development'
}